Ext.data.DWRProxy = function (f, paramMap) {
	Ext.data.DWRProxy.superclass.constructor.call(this);
	this.func = f;
	this.paramMap = paramMap||null;
};

Ext.extend(Ext.data.DWRProxy, Ext.data.DataProxy, {
	load : function(params, reader, loadCallback, scope, arg) {
		var dataProxy = this;
		dataProxy.fireEvent("beforeload", dataProxy, params);
		var args = [];
		//debugger;
		// if the param map has been established, use that, otherwise just push the params onto the array
		if(this.paramMap!==null) {
			var pLength = this.paramMap.length;
			// get the params in order
			for (i=0;i<pLength;i++) {
				if(typeof(params[i])!="function") {
					args.push(params[this.paramMap[i]]);					
				}
			}
		} else {
			if (typeof(params) == 'Array' || params instanceof Array) {
				var i;
				var l=params.length;
				for (i=0;i<l;i++) { 
					if(typeof(params[i])!="function") {
						args.push(params[i]);
					}
				}
			} else {  
				args[args.length] = params;
			}	
		}
		args[args.length] = {
			callback: function(response) {
				dataProxy.fireEvent("load", dataProxy, response, loadCallback);
				var records = reader.read(response);
		        loadCallback.call(scope, records, arg, true);
			},
  			exceptionHandler: function(message,e) {
		    	dataProxy.fireEvent("loadexception", dataProxy, message, loadCallback, e);
		        loadCallback.call(scope, null, arg, false);
		    }
		};
		
		this.func.apply(this, args);
	}
});